Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #3771: register_commands.py to handle generic scalar type #3772

Conversation

ajpotts
Copy link
Contributor

@ajpotts ajpotts commented Sep 13, 2024

Closes #3771: register_commands.py to handle generic scalar type

This PR modifies register_commands.py to handle arguments that have a generic scalar type. The following example demonstrates the new functionality.

When the following is compiled within arkouda:

    //  TEST Function
    @arkouda.registerCommand
    proc testFunc(x: ?t, x2: ?t2, array: [?D] ?t3): [D] t3 throws
    where (t == int) && (t2 == int) && (t3 == int){
        const ret = array + x + x2;
        return ret;
    }

    proc testFunc(x: ?t, x2: ?t2, array: [?D] ?t3): [D] t3 throws
    where (t != int) || (t2 != int) || (t3 != int) {
      throw new Error("Case not supported.");
    }

The following will work in arkouda:

from arkouda import *
from typing import cast

pda = ak.arange(10).reshape((2,5))
 
repMsg = generic_msg(
    cmd=f"testFunc<int64,int64,int64,2>",
    args={
        "array": pda.name,
         "x": 1,
         "x2": 7,
    },
)

create_pdarray(cast(str, repMsg))

In [2]: from arkouda import *
   ...: from typing import cast
   ...: 
   ...: pda = ak.arange(10).reshape((2,5))
   ...: 
   ...: repMsg = generic_msg(
   ...:     cmd=f"testFunc<int64,int64,int64,2>",
   ...:     args={
   ...:         "array": pda.name,
   ...:          "x": 1,
   ...:          "x2": 7,
   ...:     },
   ...: )
   ...: 
   ...: create_pdarray(cast(str, repMsg))
   ...: 
Out[2]: array([array([8 9 10 11 12]) array([13 14 15 16 17])])

@ajpotts ajpotts force-pushed the 3771-register_commands.py-to-handle-generic-scalar-type branch from 37c941b to 56f4364 Compare September 13, 2024 11:35
@ajpotts ajpotts marked this pull request as ready for review September 13, 2024 11:36
Copy link
Contributor

@jeremiah-corrado jeremiah-corrado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Contributor

@jeremiah-corrado jeremiah-corrado Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the .configs/ files (used for CI) will also need the new "scalar" parameter class

Copy link
Contributor

@jaketrookman jaketrookman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link
Member

@stress-tess stress-tess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!! Thanks so much amanda! I'm going to go ahead and merge this and I'll add a quick PR to add to the .configs for the CI like jeremiah said

Comment on lines +443 to +448
def unpack_scalar_arg_with_generic(arg_name, array_count):
"""
Generate the code to unpack a scalar argument

'scalar_count' is used to generate unique names when
a procedure has multiple array-symbol formals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def unpack_scalar_arg_with_generic(arg_name, array_count):
"""
Generate the code to unpack a scalar argument
'scalar_count' is used to generate unique names when
a procedure has multiple array-symbol formals
def unpack_scalar_arg_with_generic(arg_name, scalar_count):
"""
Generate the code to unpack a scalar argument
'scalar_count' is used to generate unique names when
a procedure has multiple scalar-symbol formals

@stress-tess stress-tess added this pull request to the merge queue Sep 17, 2024
Merged via the queue into Bears-R-Us:master with commit 8d994e6 Sep 17, 2024
10 checks passed
ajpotts added a commit to ajpotts/arkouda that referenced this pull request Sep 18, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 18, 2024
Co-authored-by: Amanda Potts <ajpotts@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

register_commands.py to handle generic scalar type
4 participants